#ifndef __SWEI_STATUS_H
#define __SWEI_STATUS_H


#include "service/include/swei_common.h"
#include "service/include/swei_package.h"

#ifdef __cplusplus
extern "C" {
#endif


#define CAN_UPLOAD_MSG_QUEUE_SIZE (64)
#define CAN_UPLOAD_WARN_MSG_QUEUE_SIZE (32) // 告警故障码队列个数


typedef enum {
    CAN_UPLOAD_NONE = 0,
    CAN_UPLOAD_DEV_INFO = 0x5001,       // 设备信息
    CAN_UPLOAD_STATUS_INFO = 0x5002,      // 状态信息
    TBOX_UPLOAD_DEV_VERSION = 0x5003,   // 设备版本信息
    TBOX_SIGNAL_STRENGTH_INFORMATION = 0x5004, // tbox信号强度信息

    CAN_UPLOAD_TAG_ID_BMS_INFO = 0x1001, // 电池基本信息
    CAN_UPLOAD_TAG_ID_BMS_CAPACITY_INFO = 0x1002, // 电池容量
    CAN_UPLOAD_TAG_ID_BMS_DISCHARGE_INFO = 0x1003, // 放电相关信息
    CAN_UPLOAD_TAG_ID_BMS_CHARGE_INFO = 0x1004, // 充电相关信息
    CAN_UPLOAD_TAG_ID_BMS_CELL_VOL_INFO1 = 0x1005,
    CAN_UPLOAD_TAG_ID_BMS_CYCLE_TIMES = 0x1006,
    CAN_UPLOAD_TAG_ID_BMS_WORKING_STA = 0x1007,
    CAN_UPLOAD_TAG_ID_BMS_WARNING_CODE = 0x4001,

    CAN_UPLOAD_TAG_ID_TBOX_BMS_INFO = 0x1010, // tbox电池信息
    CAN_UPLOAD_TAG_ID_TBOX_BMS_CHARGE = 0x1011, // tbox电池充电信息

    CAN_UPLOAD_TAG_ID_BMS_BACK_INFO = 0x1009,
    CAN_UPLOAD_TAG_ID_BMS_BACK_CAPACITY_INFO = 0x100A,
    CAN_UPLOAD_TAG_ID_BMS_BACK_DISCHARGE_INFO = 0x100B,
    CAN_UPLOAD_TAG_ID_BMS_BACK_CHARGE_INFO = 0x100C,
    CAN_UPLOAD_TAG_ID_BMS_BACK_CELL_VOL_INFO1 = 0x100D,
    CAN_UPLOAD_TAG_ID_BMS_BACK_CYCLE_TIMES = 0x100E,
    CAN_UPLOAD_TAG_ID_BMS_BACK_WORKING_STA = 0x100F,
    // CAN_UPLOAD_TAG_ID_BMS_BACK_WARNING_CODE = 0x0016,    // no use

    CAN_UPLOAD_TAG_ID_ELEC_CON_STA = 0x2001,
    CAN_UPLOAD_TAG_ID_ELEC_CON_RUNNING = 0x2002,
    CAN_UPLOAD_TAG_ID_ELEC_CON_VER = 0x2003,
    CAN_UPLOAD_TAG_ID_ELEC_CON_EEPROM = 0x001A,
    // CAN_UPLOAD_TAG_ID_ELEC_CON_SN = 0x001B,          // no use
    // CAN_UPLOAD_TAG_ID_ELEC_CON_SYS_PARAM = 0x001C,   // no use
    // CAN_UPLOAD_TAG_ID_ELEC_CON_WARNING_CODE = 0x001D,// no use

    CAN_UPLOAD_TAG_ID_BIKE_DATA1 = 0x3001,
    CAN_UPLOAD_TAG_ID_BIKE_DATA2 = 0x3002,
    CAN_UPLOAD_TAG_ID_BIKE_STATE = 0x3003
} status_event_id;


/**
 * @brief 事件队列结构体
 */
typedef struct {
    status_event_id id;
    uint32_t work_id;
    uint32_t arg;
}swei_status_evt_t;



#define CHARGE_START 0  // 充电开始前
#define CHARGE_FINISH 1 // 充电完成后



int32_t swei_status_event_update(status_event_id id, uint32_t arg);
int32_t swei_status_event_peek(common_msg_st *msg);


/**
 * @brief  定期rsrp消息
 * @param  msg              My Param doc
 * @return int32_t 
 */
int32_t swei_status_push_rsrp(void);
/**
 * @brief 定期小电池电量信息
 * @param  msg              My Param doc
 * @return int32_t 
 */
int32_t swei_status_push_libatt(void);

int32_t swei_status_push_caninfo_type1(void);
int32_t swei_status_push_caninfo_type2(void);

/**
 * @brief 禁止状态报文出队
 */
void swei_status_lock(void);
/**
 * @brief 允许状态报文出队
 */
void swei_status_unlock(void);

#ifdef __cplusplus
}
#endif

#endif // __SWEI_STATUS_H